package com.sky.service.impl;

import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import com.sky.mapper.SetmealDishMapper;
import com.sky.service.SetmealDishService;
import com.sky.vo.DishVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @projectName: sky-take-out
 * @package: com.sky.service.impl
 * @className: SetmealDishServiceImpl
 * @author: Eric
 * @description: TODO
 * @date: 2023/9/26 17:10
 * @version: 1.0
 */
@Service
public class SetmealDishServiceImpl implements SetmealDishService {
    @Autowired
    private SetmealDishMapper setmealDishMapper;


    @Override
    public List<DishVO> queryDishes(Long id) {
        List<Dish> dishList = setmealDishMapper.selectDishBySetmealId(id);
        List<DishVO> dishVOList = new ArrayList<>();
        for (Dish dish : dishList) {
            DishVO dishVO = new DishVO();
            BeanUtils.copyProperties(dish,dishVO);
            dishVOList.add(dishVO);
        }
        return dishVOList;
    }
}
